﻿using System;
using System.Collections.Generic;
using DTO;
using System.Data;
using System.Data.SqlClient;

namespace DAO
{
    public class DAOTraCuuHocSinh
    {
        public static DataTable LietKeLookupEditData(string nameproc)
        {
            try
            {
                DataTable kq = SQLDataProvider.ExecuteQuery(nameproc);
                return kq;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static DataTable LietKeLop(object makhoilop)
        {
            try
            {
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                if (makhoilop != null)
                    sqlParams.Add(new SqlParameter("@MAKHOILOP", makhoilop.ToString()));
                else
                    sqlParams.Add(new SqlParameter("@MAKHOILOP", ""));
                return SQLDataProvider.ExecuteQuery("sp_TraCuuDanhSachLop", sqlParams);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static DataTable BangDiemHocSinh(object makhoilop, object malop, string hovaten)
        {
            try
            {
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                if (malop != null)
                {
                    sqlParams.Add(new SqlParameter("@MALOP", malop.ToString()));
                    sqlParams.Add(new SqlParameter("@HOTEN", hovaten));
                    sqlParams.Add(new SqlParameter("@MAKHOILOP", ""));
                    return SQLDataProvider.ExecuteQuery("sp_BangDiemHocSinhTraCuu", sqlParams);
                }
                else
                {
                    sqlParams.Add(new SqlParameter("@MAKHOILOP", makhoilop.ToString()));
                    sqlParams.Add(new SqlParameter("@HOTEN", hovaten));
                    sqlParams.Add(new SqlParameter("@MALOP", ""));
                    return SQLDataProvider.ExecuteQuery("sp_BangDiemHocSinhTraCuu", sqlParams);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static object DanhSachHocSinh(object makhoilop, object malop, string hovaten)
        {
            try
            {
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                if (malop != null)
                {
                    sqlParams.Add(new SqlParameter("@MALOP", malop.ToString()));
                    sqlParams.Add(new SqlParameter("@HOTEN", hovaten));
                    sqlParams.Add(new SqlParameter("@MAKHOILOP", ""));
                    return SQLDataProvider.ExecuteQuery("sp_DanhSachHocSinhTraCuu", sqlParams);
                }
                else
                {
                    sqlParams.Add(new SqlParameter("@MAKHOILOP", makhoilop.ToString()));
                    sqlParams.Add(new SqlParameter("@HOTEN", hovaten));
                    sqlParams.Add(new SqlParameter("@MALOP", ""));
                    return SQLDataProvider.ExecuteQuery("sp_DanhSachHocSinhTraCuu", sqlParams);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
